package com.sky.mapper;

import com.sky.entity.Category;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.*;
import org.springframework.data.redis.connection.RedisServer;

import java.util.List;

@Mapper
public interface CateGoryMapper {

//分类分页查询
    //全部查询
    @Select("select count(1) from category order by sort")
    public int selectCount();
    @Select("select * from category order by sort limit #{start},#{end}")
    public List<Category> select(int start, int end);
    //条件查询
    @Select("select count(1) from category where name like concat('%',#{name},'%') and type = #{type} order by sort")
    int selectNameCount(String name, Integer type);
    @Select("select * from category where name like concat('%',#{name},'%') and type = #{type} order by sort limit #{start},#{end}")
    List<Category> selectName(String name, Integer type,int start, int end);
//新增分类
    @Insert("insert into category (id, type, name, sort, status, create_time, update_time, create_user, update_user) VALUES "+
    "(#{id},#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Category category);
//修改分类
    void update(Category category);
//删除分类
    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    List<Category> list(Integer type);
//根据id查询分类名称
    @Select("select name from category where id = #{id}")
    String selectByid(Long id);
}
